﻿package framework.core;

import java.sql.ResultSet;

public class UniversalTable
{
	private ObjectList m_list = ObjectList.getList();
	
	
	/**
	 * 构造
	 * @return
	 */
	public void initial(DBConnection con, String sql) throws Exception
	{
		initial(con, sql, new Conditions());
	}
	public void initial(DBConnection con, String sql, Conditions cs) throws Exception
	{
		initial(con, sql, cs, ObjectList.ALL);
	}
	public void initial(DBConnection con, String sql, Conditions cs, int page_size) throws Exception
	{
		initial(con, sql, cs, page_size, 1);
	}
	public void initial(DBConnection con, String sql, Conditions cs, int page_size,int page_num) throws Exception
	{
		initial(con, sql, cs, page_size, page_num, -1);
	}
	public void initial(DBConnection con, String sql, Conditions cs, int page_size,int page_num,int total) throws Exception
	{
		DBResult dbRs = null;
		ResultSet rs = null;
		
		try
		{
			dbRs = DBEngine.doSelect(con, sql, cs);
			rs = dbRs.getRs();
			m_list = ObjectList.fromRs(rs, page_size, page_num, -1);
		} finally 
		{
			if(rs != null)
				rs.close();
			if(dbRs != null)
				dbRs.clear();
			
		}
	}
	
	public ObjectList getList()
	{
		return m_list;
	}
}


